package adv4;

import java.util.Calendar;

public class CalTest2 {

	public static void main(String[] args) {
		// add和roll
		Calendar c = Calendar.getInstance();
		c.add(Calendar.DATE, 50);
		System.out.println(c.getTime());
		Calendar c2 = Calendar.getInstance();
		c2.roll(Calendar.DATE, 50);
		System.out.println(c2.getTime());
		// //////////////////////////////
		c.set(Calendar.YEAR, 2016);
		c.set(Calendar.MONTH, Calendar.FEBRUARY);
		c.set(Calendar.DAY_OF_MONTH, 1);
		// >
		int days = c.getActualMaximum(Calendar.DAY_OF_MONTH);
		System.out.println("今年二月多少天：" + days);
		int weeks = c.getActualMaximum(Calendar.WEEK_OF_YEAR);
		System.out.println("2016年有" + weeks + "周");
		// 计算 下一个周二是哪天
		Calendar c3 = Calendar.getInstance();
		c3.add(Calendar.WEEK_OF_MONTH, 1);
		// 考虑是否在周二后还是前
		c3.set(Calendar.DAY_OF_WEEK, Calendar.TUESDAY);
		System.out.println("下一个周二是：");
		System.out.println(c3.getTime());
		// while (true) {
		// c3.add(Calendar.DAY_OF_WEEK, 1);
		// if (c3.get(Calendar.DAY_OF_WEEK) == Calendar.TUESDAY) {
		// System.out.println("下一个周二是：");
		// System.out.println(c3.getTime());
		// break;
		// }
		// }
		// c3.add(Calendar.TUESDAY, 1);

	}

}
